home *** CD-ROM | disk | FTP | other *** search
/ Champak 130 / Vol 130.iso / games / right_co.swf / scripts / frame_25 / DoAction.as
Encoding:
Text File  |  2008-09-23  |  7.6 KB  |  276 lines

  1. function initTarget()
  2. {
  3.    target_mc = totaltarget_mc.target_mc;
  4.    target_mc.gor = 0;
  5.    now_target = 1;
  6.    var _loc2_ = 1;
  7.    while(_loc2_ <= 8)
  8.    {
  9.       if(_loc2_ == 1 or _loc2_ == 5)
  10.       {
  11.          this.target_mc["target" + _loc2_ + "_mc"].objType = 1;
  12.       }
  13.       if(_loc2_ == 2 or _loc2_ == 6)
  14.       {
  15.          this.target_mc["target" + _loc2_ + "_mc"].objType = 3;
  16.       }
  17.       if(_loc2_ == 3 or _loc2_ == 7)
  18.       {
  19.          this.target_mc["target" + _loc2_ + "_mc"].objType = 2;
  20.       }
  21.       if(_loc2_ == 4 or _loc2_ == 8)
  22.       {
  23.          this.target_mc["target" + _loc2_ + "_mc"].objType = 4;
  24.       }
  25.       if(_loc2_ == 1)
  26.       {
  27.          this.target_mc["target" + _loc2_ + "_mc"].gotoAndStop(1);
  28.       }
  29.       else
  30.       {
  31.          this.target_mc["target" + _loc2_ + "_mc"].gotoAndStop(4);
  32.       }
  33.       _loc2_ = _loc2_ + 1;
  34.    }
  35. }
  36. function initObj()
  37. {
  38.    var _loc2_ = 1;
  39.    while(_loc2_ <= 5)
  40.    {
  41.       if(this["obj" + _loc2_ + "_mc"].objNum == undefined)
  42.       {
  43.          this["obj" + _loc2_ + "_mc"].objNum = _loc2_;
  44.       }
  45.       if(_loc2_ != 1)
  46.       {
  47.          this["obj" + _loc2_ + "_mc"]._x = obj1_mc._x - (_loc2_ - 1) * obj_space;
  48.       }
  49.       gof = Math.floor(Math.random() * 4) + 1;
  50.       this["obj" + _loc2_ + "_mc"].gotoAndStop(gof);
  51.       if(this["backY" + _loc2_] == undefined)
  52.       {
  53.          this["backY" + _loc2_] = this["obj" + _loc2_ + "_mc"]._y;
  54.       }
  55.       _loc2_ = _loc2_ + 1;
  56.    }
  57.    _loc2_ = 1;
  58.    while(_loc2_ <= 5)
  59.    {
  60.       idx = Math.floor(Math.random() * 5) + 1;
  61.       this["obj" + _loc2_ + "_mc"]._y = this["backY" + idx];
  62.       _loc2_ = _loc2_ + 1;
  63.    }
  64. }
  65. function clickStartBtn()
  66. {
  67.    msg_mc.gotoAndStop(1);
  68.    game_start = true;
  69. }
  70. function depthUp()
  71. {
  72.    brdNnum_mc.nextFrame();
  73.    i = 1;
  74.    while(i <= 8)
  75.    {
  76.       if(target_mc["target" + now_target + "_mc"].getDepth() < target_mc["target" + i + "_mc"].getDepth())
  77.       {
  78.          target_mc["target" + now_target + "_mc"].swapDepths(target_mc["target" + i + "_mc"]);
  79.       }
  80.       i++;
  81.    }
  82.    if(brdNnum_mc._currentframe == brdTnum_mc._currentframe)
  83.    {
  84.       game_start = false;
  85.       m_level++;
  86.       sound_mc.gotoAndPlay("CLEAR");
  87.       level_init();
  88.    }
  89. }
  90. function level_init()
  91. {
  92.    if(m_level < 6)
  93.    {
  94.       levelNum_mc.gotoAndStop(m_level);
  95.       msg_mc.gotoAndStop(m_level + 1);
  96.       brdNnum_mc.gotoAndStop(1);
  97.       gof = dfObj + (m_level - 1) * plusObj + 1;
  98.       brdTnum_mc.gotoAndStop(gof);
  99.       obj_space -= 11;
  100.       obj_speed += 0.8;
  101.       obj1_mc._x = -86;
  102.       Ntime = 0;
  103.       initObj();
  104.    }
  105.    else
  106.    {
  107.       stopAllSounds();
  108.       msg_mc.gotoAndStop(7);
  109.    }
  110. }
  111. function corn_plus()
  112. {
  113.    loadVariables("http://www.ibravo.com/Web/Game/Popup/UpdatePoint.aspx?corn=10",this,"POST");
  114. }
  115. stop();
  116. var keybuf = 0;
  117. var rt_speed = 5;
  118. var obj_speed = 3;
  119. var obj_space = 400;
  120. var plusObj = 5;
  121. var dfObj = 10;
  122. var obj_endX = 400;
  123. var m_level = 1;
  124. var game_start = false;
  125. var dontMove = false;
  126. var fps = 30;
  127. var Ttime = 100;
  128. var Ntime = 0;
  129. var mnTime = 120;
  130. initTarget();
  131. initObj();
  132. level_init();
  133. this.onEnterFrame = function()
  134. {
  135.    if(game_start == true)
  136.    {
  137.       if(dontMove == false)
  138.       {
  139.          Ntime++;
  140.          temp = Ntime / fps;
  141.          if(temp == 0)
  142.          {
  143.             temp = 1;
  144.          }
  145.          gof = Math.round(temp * time_mc._totalframes / Ttime);
  146.          time_mc.gotoAndStop(gof);
  147.          if(Ntime / fps >= Ttime and msg_mc._currentframe != 8)
  148.          {
  149.             game_start = false;
  150.             stopAllSounds();
  151.             msg_mc.gotoAndStop(8);
  152.          }
  153.       }
  154.       if(Key.isDown(37) and dontMove == false)
  155.       {
  156.          if(keybuf == 0 and target_mc.gor == 0)
  157.          {
  158.             keybuf = 10;
  159.             target_mc.gor = -45;
  160.             target_mc["target" + now_target + "_mc"].gotoAndStop(4);
  161.             if(now_target == 8)
  162.             {
  163.                now_target = 1;
  164.             }
  165.             else
  166.             {
  167.                now_target++;
  168.             }
  169.             target_mc["target" + now_target + "_mc"].gotoAndStop(1);
  170.             sound_mc.gotoAndPlay("ROTATE");
  171.          }
  172.       }
  173.       else if(Key.isDown(39) and dontMove == false)
  174.       {
  175.          if(keybuf == 0 and target_mc.gor == 0)
  176.          {
  177.             keybuf = 10;
  178.             target_mc.gor = 45;
  179.             target_mc["target" + now_target + "_mc"].gotoAndStop(4);
  180.             if(now_target == 1)
  181.             {
  182.                now_target = 8;
  183.             }
  184.             else
  185.             {
  186.                now_target--;
  187.             }
  188.             target_mc["target" + now_target + "_mc"].gotoAndStop(1);
  189.             sound_mc.gotoAndPlay("ROTATE");
  190.          }
  191.       }
  192.       else if(Key.isDown(40))
  193.       {
  194.          if(keybuf == 0 and target_mc.gor == 0)
  195.          {
  196.             keybuf = 10;
  197.             var _loc2_ = 1;
  198.             while(_loc2_ <= 5)
  199.             {
  200.                var _loc3_ = this["obj" + _loc2_ + "_mc"]._currentframe;
  201.                if(Math.abs(this["obj" + _loc2_ + "_mc"]._y - backY1) < 2 and _loc3_ <= 4)
  202.                {
  203.                   this["obj" + _loc2_ + "_mc"]._y = backY2;
  204.                }
  205.                else if(Math.abs(this["obj" + _loc2_ + "_mc"]._y - backY2) < 2 and _loc3_ <= 4)
  206.                {
  207.                   this["obj" + _loc2_ + "_mc"]._y = backY3;
  208.                }
  209.                else if(Math.abs(this["obj" + _loc2_ + "_mc"]._y - backY3) < 2 and _loc3_ <= 4)
  210.                {
  211.                   this["obj" + _loc2_ + "_mc"]._y = backY4;
  212.                }
  213.                else if(Math.abs(this["obj" + _loc2_ + "_mc"]._y - backY4) < 2 and _loc3_ <= 4)
  214.                {
  215.                   this["obj" + _loc2_ + "_mc"]._y = backY5;
  216.                }
  217.                else if(Math.abs(this["obj" + _loc2_ + "_mc"]._y - backY5) < 2 and _loc3_ <= 4)
  218.                {
  219.                   this["obj" + _loc2_ + "_mc"]._y = backY1;
  220.                }
  221.                sound_mc.gotoAndPlay("MOVE");
  222.                _loc2_ = _loc2_ + 1;
  223.             }
  224.          }
  225.       }
  226.       else if(Key.isDown(38))
  227.       {
  228.          if(keybuf == 0 and target_mc.gor == 0)
  229.          {
  230.             keybuf = 10;
  231.             _loc2_ = 1;
  232.             while(_loc2_ <= 5)
  233.             {
  234.                _loc3_ = this["obj" + _loc2_ + "_mc"]._currentframe;
  235.                if(Math.abs(this["obj" + _loc2_ + "_mc"]._y - backY1) < 2 and _loc3_ <= 4)
  236.                {
  237.                   this["obj" + _loc2_ + "_mc"]._y = backY5;
  238.                }
  239.                else if(Math.abs(this["obj" + _loc2_ + "_mc"]._y - backY2) < 2 and _loc3_ <= 4)
  240.                {
  241.                   this["obj" + _loc2_ + "_mc"]._y = backY1;
  242.                }
  243.                else if(Math.abs(this["obj" + _loc2_ + "_mc"]._y - backY3) < 2 and _loc3_ <= 4)
  244.                {
  245.                   this["obj" + _loc2_ + "_mc"]._y = backY2;
  246.                }
  247.                else if(Math.abs(this["obj" + _loc2_ + "_mc"]._y - backY4) < 2 and _loc3_ <= 4)
  248.                {
  249.                   this["obj" + _loc2_ + "_mc"]._y = backY3;
  250.                }
  251.                else if(Math.abs(this["obj" + _loc2_ + "_mc"]._y - backY5) < 2 and _loc3_ <= 4)
  252.                {
  253.                   this["obj" + _loc2_ + "_mc"]._y = backY4;
  254.                }
  255.                sound_mc.gotoAndPlay("MOVE");
  256.                _loc2_ = _loc2_ + 1;
  257.             }
  258.          }
  259.       }
  260.       else
  261.       {
  262.          keybuf = 0;
  263.       }
  264.    }
  265.    if(target_mc.gor > 0)
  266.    {
  267.       target_mc.gor -= rt_speed;
  268.       target_mc._rotation += rt_speed;
  269.    }
  270.    if(target_mc.gor < 0)
  271.    {
  272.       target_mc.gor += rt_speed;
  273.       target_mc._rotation -= rt_speed;
  274.    }
  275. };
  276.